package com.basic.sys.controller;


import com.alibaba.fastjson.JSON;
import com.basic.common.result.WebResult;
import com.basic.sys.domain.CommonBo;
import com.basic.sys.domain.SelPressureForm;
import com.basic.sys.service.PressureService;
import org.apache.logging.log4j.util.Strings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Collections;
import java.util.List;

/**
 * 数据-管理
 */
@RestController
@RequestMapping(value = "/api/pressure")
public class PressureController {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
    @Autowired
    PressureService pressureService;

    /**
     *查询压力列表
     */
    @RequestMapping(value = "/selPressureList")
    public WebResult selPressureList(SelPressureForm sel){
        return WebResult.success(pressureService.selPressureList(sel));
    }

    /**
     *查询用电量与供水趋势图-七日
     */
    @RequestMapping(value = "/selEleLAndWaterList")
    public WebResult selEleLAndWaterList(@RequestBody SelPressureForm sel){
        logger.info(" ---------sel---------"+ JSON.toJSONString(sel));
        // 反转List集合的顺序
        List<CommonBo> list = pressureService.selEleLAndWaterList(sel);
        if(list !=null || list.size()>0){
            Collections.reverse(list);
        }
        return WebResult.success(list);
    }

    /**
     *查询用电量与供水 能耗比
     */
    @RequestMapping(value = "/selEleLAndWaterProportion")
    public WebResult selEleLAndWaterProportion(@RequestBody SelPressureForm sel){
        logger.info(" ---------sel---------"+ JSON.toJSONString(sel));
        return WebResult.success(pressureService.selEleLAndWaterProportion(sel));
    }



}
